from TTS.tts.configs.xtts_config import XttsConfig
from TTS.tts.models.xtts import Xtts
from TTS.utils.audio import numpy_transforms

device_num = 3

config = XttsConfig()
config.load_json("config.json")
model = Xtts.init_from_config(config)
model.load_checkpoint(config, checkpoint_dir="./", eval=True)
model.cuda(device_num)

outputs = model.synthesize(
    "It took me quite a long time to develop a voice and now that I have it I am not going to be silent.",
    config,
    speaker_wav="./samples/male.wav",
    gpt_cond_len=3,
    language="en",
)
numpy_transforms.save_wav(wav=outputs['wav'], path="output_model.wav", sample_rate=24000)
